package com.itheima.web.controller;

import com.itheima.web.manager.UserManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.management.modelmbean.RequiredModelMBean;

@RestController
public class UserController {

    @Autowired
    private UserManager userManager;

    //用户列表
    @GetMapping("/manage/users")
    public ResponseEntity findUserList(
            @RequestParam(value = "page",defaultValue = "1")Integer pageNum,
            @RequestParam(value = "pagesize",defaultValue = "10")Integer pageSize){
        return userManager.findUserList(pageNum,pageSize);
    }

    //用户详情
    @GetMapping("/manage/users/{userId}")
    public ResponseEntity findUserInfo(@PathVariable Long userId){
        return userManager.findUserInfo(userId);
    }


    //动态列表
    @GetMapping("/manage/messages")
    public ResponseEntity findUserMovementList(
            @RequestParam(value = "page",defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize",defaultValue = "10") Integer pageSize,
            @RequestParam(value = "uid",required = false) Long userId ,
            String state){
        return userManager.findUserMovementList(pageNum,pageSize,userId,state);
    }

    //动态详情
    @GetMapping("/manage/messages/{publishId}")
    public ResponseEntity findMovementVoById(@PathVariable String publishId){
        return userManager.findMovementVoById(publishId);
    }

    //评论详情
    @GetMapping("/manage/messages/comments")
    public ResponseEntity findCommentVoByPage(
            @RequestParam(value = "messageID",required = false) String publishId,
            @RequestParam(value = "page",defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize",defaultValue = "10") Integer pageSize){
        return userManager.findCommentVoByPage(publishId,pageNum,pageSize);

    }

    //查询视频列表
    @GetMapping("/manage/videos")
    public ResponseEntity findVideoVoByPage(
            @RequestParam(value = "uid",required = false) Long userId,
            @RequestParam(value = "page",defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize",defaultValue = "10") Integer pageSize){
        return userManager.findVideoVoByPage(userId,pageNum,pageSize);
    }

}
